package at.fhooe.im440.pandora.entities;

import java.awt.Graphics2D;
import java.awt.geom.Point2D;

import at.fhooe.im440.pandora.collision.CircleCollider;
import at.fhooe.im440.pandora.core.Core;

public class AsteroidEmmitter extends Entity {

	//ceate Astroid on every e.g 10th frame
	final static float FREQUENCY = 01.0f;
	
	
	//default settings
	private static final int MAXSIZE = 70;
	private static final int MINSIZE = 5;
	private static final float SPIN_MAX = 0.06f;
	private static final float MIN_SPEED = 1.0f;
	private static final float MAX_SPEED = 3.0f;	
	
	/**
	 * @param name
	 * @param core
	 */
	
	private EmmitterSettings es;
	
	public AsteroidEmmitter(String name, Core core) {
		super(name, core, 0, 0, 0);
		//default EmmitterSettings
		es = new EmmitterSettings (MAXSIZE, MINSIZE, SPIN_MAX, MAX_SPEED, MIN_SPEED, FREQUENCY);
	}
	
	public AsteroidEmmitter(String name, Core core, EmmitterSettings es){
		super(name, core, 0, 0, 0);
		//default EmmitterSettings
		this.es = es;
	}
	

	@Override
	public void update() {
		if(createAsteroid()){
			core.entityManager.addEntity(new AsteroidEntity("aster" + " " + System.currentTimeMillis(), core, es));
		}
	}

	private boolean createAsteroid() {
//		if(core.isDebug)
//		{
//			if(core.collisionTester.m_Enemies.size() == 0)
//			{
//				return true;
//			}
//			else
//			{
//				return false;
//			}
//		}
//		else
//		{
			return (int)(Math.random()*(int)(60/es.getFrequency())) == 1;
//		}
	}

	@Override
	public void render(Graphics2D g) {
		// TODO Auto-generated method stub

	}

	@Override
	public Point2D getPosition() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setPosition(float x, float y) {
		// TODO Auto-generated method stub

	}

	@Override
	public void collided(CircleCollider col) {
		// TODO Auto-generated method stub
		
	}

}
